﻿CREATE TABLE [dbo].[Database] (
    [DatabaseID]               INT            IDENTITY (1, 1) NOT NULL,
    [ServiceID]                INT            NOT NULL,
    [DatabaseName]             VARCHAR (4000)  NULL,
    [Collation]                VARCHAR (4000)  NULL,
    [Owner]                    VARCHAR (4000)  NULL,
    [RecoveryModel]            VARCHAR (4000)   NULL,
    [State]                    VARCHAR (4000)  NULL,
    [CompatibilityLevel]       VARCHAR (4000)   NULL,
    [DatabaseVersion]          VARCHAR (4000)   NULL,
    [OriginalDatabaseVersion]  VARCHAR (4000)   NULL,
    [CreateDate]               DATETIME       NULL,
    [LatestFullBackup]         DATETIME       NULL,
    [LatestDifferentialBackup] DATETIME       NULL,
    [LatestLogBackup]          DATETIME       NULL,
    [LatestFullBackupStart]    DATETIME       NULL,
    [LatestFullBackupSize]     INT            NULL,
    [IsAutoShrink]             BIT            NULL,
    [PageVerify]               INT            NULL,
    [AutoUpdate]               BIT            NULL,
    [CPUPercent]               DECIMAL (5, 2) NULL,
    [SourceDatabaseId] INT NULL, 
    [LatestBackUpPath] VARCHAR(4000) NULL, 
    CONSTRAINT [PK_Database] PRIMARY KEY CLUSTERED ([DatabaseID] ASC),
    CONSTRAINT [FK_Database_Service] FOREIGN KEY ([ServiceID]) REFERENCES [dbo].[Service] ([ServiceID]), 
    CONSTRAINT [FK_SourceDatabase_Database] FOREIGN KEY ([SourceDatabaseId]) REFERENCES [Database]([DatabaseID])
);







